﻿@using Ornament.MemberShip
@model IList<Ornament.MemberShip.UserGroup>
<p>
    <button id="selectAll" type="button">
        全选</button>
    <button id="unSelected" type="button">
        反选</button>
    <button id="unSelectAll" type="button">
        全部选择</button>
</p>
<script type="text/javascript">
    $("#selectAll").button().click(function () {
        $("#UserGroupSelector input").attr("checked", true);
    });
    $("#unSelectAll").button().click(function () {
        $("#UserGroupSelector input").attr("checked", false);
    });
    $("#unSelected").button().click(function () {
        $("#UserGroupSelector input").each(function () {
            $(this).attr("checked", !$(this).attr("checked"));
        })
    });

</script>
<style type="text/css">
    .item
    {
        width: 140px;
        float: left;
        margin: 5px;
    }
</style>
<div id="UserGroupSelector">
    @foreach (var item in Ornament.Web.OrnamentContext.Current.GetDaoFactory<IMemberShipFactory>().CreateUserGroupDao().GetAll())
    {        
        <span class="item">
            <label for="@item.Id">@item.Name</label>
            <input id="@item.Id" type="checkbox" name="selectorUserGroups"  value="@item.Id"/>
        </span>       
    }
    <div style="clear: both">
    </div>
</div>
